<?php

namespace app\admin\controller;

use app\admin\service\OutletCarService;
use app\admin\service\OutletsAgreementService;
use app\admin\service\OutletsService;
use app\admin\service\SurchargeService;

class OutletsController extends CommonController
{
    // 获取网点列表
    public function getPageListByPoint(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 网点详情
    public function getInfoByPoint(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getInfo();
        return $this->return_result($this->returnData);
    }

    // 添加网点
    public function toAddByPoint(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 编辑网点
    public function toEditByPoint(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toEdit();
        return $this->return_result($this->returnData);
    }

    // 更新网点状态
    public function updateStatusByPoint(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    // 删除网点
    public function toDelByPoint(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

    // 获取网点的车辆列表
    public function getPageListByCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletCarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 添加网点车
    public function toAddByCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletCarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 编辑网点车
    public function toEditByCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletCarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toEdit();
        return $this->return_result($this->returnData);
    }

    // 更新网点车的状态
    public function updateStatusByCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletCarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    // 删除网点车
    public function toDelByCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletCarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

    // 获取附加费列表
    public function getPageListBySurcharge(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(SurchargeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 添加附加费
    public function toAddBySurcharge(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(SurchargeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 编辑附加费
    public function toEditBySurcharge(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(SurchargeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toEdit();
        return $this->return_result($this->returnData);
    }

    // 更新附加费状态
    public function updateStatusBySurcharge(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(SurchargeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    // 删除附加费
    public function toDelBySurcharge(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(SurchargeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

    // 获取协议
    public function getPageListByAgreement(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsAgreementService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 协议详情
    public function getInfoByAgreement(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsAgreementService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getInfo();
        return $this->return_result($this->returnData);
    }

    // 添加协议
    public function toAddByAgreement(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsAgreementService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 编辑协议
    public function toEditByAgreement(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsAgreementService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toEdit();
        return $this->return_result($this->returnData);
    }

    // 更新协议状态
    public function updateStatusByAgreement(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsAgreementService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    // 删除协议
    public function toDelByAgreement(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OutletsAgreementService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }
}